<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>客房信息修改</title>
<!--bootstrap-->
<script type="text/javascript" th:src="@{/bootstrap3/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/npm.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/popper.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap-popover.js}"></script>
<script type="text/javascript" th:src="@{/js/jquery.dropdown.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap-theme.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap.css}" />
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap-theme.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap.min.css}" />
<!--layui-->
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}"/>
</head>
<script type="text/javascript">
	function save_category(id){
		var name = $("#name").val();
		var code = $("#code").val();
		var bedprice = $("#bedprice").val();
		var roomprice= $("#roomprice").val();
		var description = $("#description").val();
		if(name==""||code==""||bedprice==""||roomprice==""||description==""){
			document.getElementById("udpate_tips").innerHTML = '<div class="alert alert-danger" role="alert">输入的数据不合法</div>';
		}else{
			$.ajax({
				url:"updateadmincategory",
				type:"post",
				dataType:"json",
				data:{id:id,name:name,code:code,bedprice:bedprice,roomprice:roomprice,description:description},
				async:true,
				success:function(data){
					if(data==1){
						document.getElementById("udpate_tips").innerHTML = '<div class="alert alert-success" role="alert">修改成功！</div>';
					}else{
						document.getElementById("udpate_tips").innerHTML = '<div class="alert alert-warning" role="alert">内部故障！</div>';
					}
				},
				error:function(){
					document.getElementById("udpate_tips").innerHTML = '<div class="alert alert-warning" role="alert">内部故障！</div>';
				}
			});
		}
	}
</script>
<body>
<div class="container-fluid">
	<div class="panel panel-default">
		<div id="udpate_tips">
		</div>
		<div class="panel-body" style="height: 450px;overflow: auto;">
			<div class="row">
				<div class="col-sm-3"></div>
				<div class="col-sm-6">
					<form>
						<div class="form-group">
							<label for="id">序号：</label>
							<label th:text="${category.id}"></label>
						</div>
						<div class="form-group">
							<label for="name">类型：</label>
							<input id="name" type="text" class="form-control" th:value="${category.name}" maxlength="25"/>							
						</div>
						<div class="form-group">
							<label for="code">编号：</label>
							<input id="code" type="text" class="form-control" th:value="${category.code}" />
						</div>
						<div class="form-group">
							<label for="bedprice">床价：</label>
							<input id="bedprice" type="number" class="form-control" th:value="${category.bedprice}" />
						</div>
						<div class="form-group">
							<label for="roomprice">房价：</label>
							<input id="roomprice" type="number" class="form-control" th:value="${category.roomprice}" />
						</div>
						<div class="form-group">
							<label for="description">描述：</label>
							<textarea id="description" class="layui-textarea" th:text="${category.description}">
							</textarea>							
						</div>
						<div class="form-group">
							<a class="form-control btn btn-warning" href="javascript:void(0)" th:onclick="save_category([[${category.id}]])">保存</a>							
						</div>
					</form>
				</div>
				<div class="col-sm-3"></div>
			</div>
		</div>
	</div>
</div>
</body>
</html>
